package com.maoxx.humanresourcemanage_service.exception;

import com.maoxx.humanresourcemanage_service.enums.BaseEnum;
import lombok.Getter;

/**
 * @className: ServiceException
 * @author: Maoxx
 * @date: 2024/11/6 19:30
 * @Version: 1.0
 * @description:
 */

@Getter
public class ServiceException extends RuntimeException {
    private Integer code;

    public ServiceException(Integer code,String message){
        super(message);
        this.code = code;
    }

    /**
     * 使用BaseEnum枚举类型创建ServiceException异常
     *
     * @param e BaseEnum枚举类型的实例，包含异常信息和错误码
     */
    public ServiceException(BaseEnum e){
        super(e.getMessage());
        this.code = e.getCode();
    }
}
